import React, {Component} from 'react';
import {StyleSheet, Text, View, Image, ScrollView, Alert, Dimensions, ImageBackground, RefreshControl, FlatList} from 'react-native';
import {Button, WhiteSpace, WingBlank, Flex, Carousel, List, Grid, Icon, Provider, Toast, Modal, Radio} from '@ant-design/react-native';
import {outlineGlyphMap} from '@ant-design/icons-react-native/lib/outline';
import {getPackageEdit} from '~/api/order';
import {
    getParkingAreaById,
    getParkingDataInfo,
    getParkingOrderInfo,
    getParkingPlanInfo,
    setParkingOrderAgreementState,
    setParkingOrderContractState,
    setParkingOrderDepositState,
    setParkingOrderGiftState,
    setParkingOrderIsComplete,
    setParkingOrderIsFullPay,
    setParkingOrderPayMode,
    setParkingOrderCoinState,
} from '~/api/parking';
import {getBankLoanInfo, getApplyInfo, getApplyInfoByOrderId} from '~/api/bank';
const RadioItem = Radio.RadioItem;
import {connect} from 'react-redux';
import Parkpublics from '~/components/process/parkpublics';
import moment from 'moment';
const mapGetter = (state) => {
    return {
        userinfo: state.userinfo,
        system: state.system,
    };
};
class MyOrderInfo extends Component {
    static navigationOptions = {
        title: '车位订单详情',
        headerTransparent: true,
        headerTintColor: 'white',
    };

    constructor(props) {
        //调用基类的所有的初始化方法
        super(props);
        // 设置当前组件的属性
        this.state = {
            parkorderid: this.props.navigation.getParam('parkorderid'),
            orderinfo: [],
            parkinfo: [],
            packagelist: [],
            parkplanlist: [],
            banklist: [],
            appliID: 0,
            applylist: [],
            ParkingDataID: '',
            loantype: 0, //0为未选择金融产品  1已有金融产品
            moneytype: 0, //0未上传支付凭证  1已上传支付凭证
            imgurl: '',
            fileLong: 0,
            fileWide: 0,
            longwide: '',
            refreshing: false,
        };
        this.GetList();
        getApplyInfoByOrderId(this.state.parkorderid).then((r) => {
            if (r.code === 0) {
                this.setState({
                    loantype: r.data == '' ? 0 : 1,
                });
            } else {
                console.log(r.msg);
            }
        });
        this.changebuy = (stateid) => {
            //stateid  1全款  2零首付
            Modal.alert('提示', '更换支付方式后为全款支付，确认立付尾款？', [
                {
                    text: '取消',
                },
                {
                    text: '确定',
                    onPress: () => {
                        setParkingOrderPayMode({
                            id: this.state.parkorderid,
                            state: stateid,
                        }).then((r) => {
                            if (r.code === 0) {
                                if (stateid == 1) {
                                    this.props.navigation.push('PayMoney', {
                                        orderid: this.state.parkorderid,
                                        parkid: this.state.ParkingDataID,
                                    });
                                } else {
                                    this.props.navigation.push('PayLoan', {
                                        params: this.state.ParkingDataID,
                                        orderid: this.state.parkorderid,
                                    });
                                }
                            } else {
                                Toast.info(r.msg, 1);
                            }
                        });
                    },
                },
            ]);
        };
    }
    _onRefresh() {
        this.GetList();
    }
    GetList() {
        getParkingOrderInfo(this.state.parkorderid).then((r) => {
            if (r.code === 0) {
                this.setState({
                    orderinfo: r.data,
                    appliID: r.data.BankApplyID,
                    ParkingDataID: r.data.ParkingDataID,
                    moneytype: r.data.picList == '' ? 0 : 1,
                });
                //获取车位信息
                this.getparkinfo(r.data.ParkingDataID);
                //获取套餐信息
                this.getpackage(r.data.ParkingPackageID);
                this.getparkplan(r.data.ParkingPlanID);
            } else {
                Alert.alert(r.msg);
            }
        });
    }
    AuditOrder(ParkingOrderID) {
        Modal.alert('提示', '确认审核订单？', [
            {
                text: '取消',
            },
            {
                text: '通过',
                onPress: () => {
                    setParkingOrderDepositState({
                        ParkingOrderID: ParkingOrderID,
                    }).then((r) => {
                        if (r.code === 0) {
                            this.GetList();
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                },
            },
        ]);
    }
    ConfirmOrder(ParkingOrderID) {
        Modal.alert('提示', '确认签订认购协议？', [
            {
                text: '取消',
            },
            {
                text: '确认',
                onPress: () => {
                    setParkingOrderContractState({
                        ParkingOrderID: ParkingOrderID,
                        state: 1,
                    }).then((r) => {
                        if (r.code === 0) {
                            this.GetList();
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                },
            },
        ]);
    }
    ConfirmAgreeOrder(ParkingOrderID) {
        Modal.alert('提示', '确认签订购车协议？', [
            {
                text: '取消',
            },
            {
                text: '确认',
                onPress: () => {
                    setParkingOrderAgreementState({
                        ParkingOrderID: ParkingOrderID,
                        state: 1,
                    }).then((r) => {
                        if (r.code === 0) {
                            this.GetList();
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                },
            },
        ]);
    }
    ConfirmFull(ParkingOrderID) {
        Modal.alert('提示', '确认收到全款？', [
            {
                text: '取消',
            },
            {
                text: '确认',
                onPress: () => {
                    setParkingOrderIsFullPay({
                        ParkingOrderID: ParkingOrderID,
                    }).then((r) => {
                        if (r.code === 0) {
                            this.GetList();
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                },
            },
        ]);
    }
    ConfirmLoan(ParkingOrderID) {
        Modal.alert('提示', '确认收到贷款？', [
            {
                text: '取消',
            },
            {
                text: '确认',
                onPress: () => {
                    setParkingOrderIsComplete({
                        ParkingOrderID: ParkingOrderID,
                    }).then((r) => {
                        if (r.code === 0) {
                            this.GetList();
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                },
            },
        ]);
    }
    Comfirecoin(ParkingOrderID) {
        Modal.alert('提示', '确认发放现金券？', [
            {
                text: '取消',
            },
            {
                text: '确认',
                onPress: () => {
                    setParkingOrderCoinState({
                        ParkingOrderID: ParkingOrderID,
                    }).then((r) => {
                        if (r.code === 0) {
                            this.GetList();
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                },
            },
        ]);
    }
    getparkinfo(id) {
        getParkingDataInfo(id).then((r) => {
            if (r.code === 0) {
                this.state.orderinfo.AreaBuilt = r.data.AreaBuilt;
                this.state.orderinfo.AreaInner = r.data.AreaInner;
                this.state.orderinfo.AreaName = r.data.AreaName;
                this.state.orderinfo.BuildingName = r.data.BuildingName;
                this.state.orderinfo.PriceSell = this.state.orderinfo.ParkingPirce;
                this.state.orderinfo.ValidBegin = moment(this.state.orderinfo.ValidBegin, 'YYYY-MM-DD HH:mm:ss').toDate();
                this.state.orderinfo.ValidEnd = moment(this.state.orderinfo.ValidEnd, 'YYYY-MM-DD HH:mm:ss').toDate();
                this.state.orderinfo.PriceMarket = r.data.PriceMarket;
                this.setState({
                    parkinfo: r.data,
                });
                getParkingAreaById(r.data.ParkingAreaID).then((r) => {
                    if (r.code === 0) {
                        this.setState({
                            imgurl: r.data.httpHead + '/' + r.data.data.ParkingAreaID + '/' + r.data.data.FileName,
                            fileLong: r.data.data.FileLong,
                            fileWide: r.data.data.FileWide,
                            longwide: (r.data.data.FileLong / r.data.data.FileWide).toFixed(2),
                        });
                    }
                });
            } else {
                Toast.info(r.msg);
            }
        });
    }
    getpackage(id) {
        getPackageEdit({
            order_id: id,
        }).then((r) => {
            if (r.code === 0) {
                this.setState({
                    packagelist: r.data.order,
                });
            } else {
                console.log(r.msg);
            }
        });
    }
    getparkplan(id) {
        getParkingPlanInfo(id).then((r) => {
            if (r.code === 0) {
                this.setState({
                    parkplanlist: r.data,
                });
            }
        });
    }
    payment(ParkingOrderID) {
        this.props.navigation.push('Paymentmoney', {
            orderid: ParkingOrderID,
        });
    }
    //更换套餐
    changepackage() {
        this.props.navigation.push('ChangeGift', {
            parkingplanitemid: this.state.orderinfo.ParkingPlanItemID,
            packageorderid: this.state.packagelist.OrderDataID,
            parkorderid: this.state.parkorderid,
            refresh: () => {
                this._onRefresh();
            },
        });
    }
    render() {
        return (
            <ScrollView
                refreshControl={
                    <RefreshControl
                        refreshing={this.state.refreshing}
                        onRefresh={() => {
                            this._onRefresh();
                        }}
                    />
                }>
                <View style={{width: '100%', height: '100%'}}>
                    <View style={{width: '100%', flexDirection: 'column'}}>
                        <ImageBackground
                            style={{height: 180, resizeMode: 'repeat', justifyContent: 'center'}}
                            source={require('~/assets/public/juxing.png')}
                        />
                        <View style={{margin: 10, width: '90%', marginLeft: '5%', marginRight: '5%', marginTop: -90}}>
                            <Parkpublics parkinginfo={this.state.orderinfo} />
                        </View>
                        <View
                            style={{
                                backgroundColor: 'white',
                                width: '90%',
                                marginLeft: '5%',
                                marginRight: '5%',
                                paddingBottom: 20,
                                marginTop: 10,
                                padding: 10,
                                borderRadius: 5,
                            }}>
                            {this.state.orderinfo.state === '作废' && (
                                <Flex>
                                    <Text style={{color: 'gray', fontSize: 12}}>订单已作废，如有疑问，请联系客服：023-67586710</Text>
                                </Flex>
                            )}
                            <Flex style={{marginTop: 20, width: '100%'}}>
                                <Text style={{color: 'gray', width: '30%'}}>订单状态:</Text>
                                <Text style={{color: 'gray', width: '40%'}}>{this.state.orderinfo.state}</Text>
                                <Text style={{width: '30%'}} />
                            </Flex>
                            <View style={{width: '100%', height: 1, borderWidth: 1, borderColor: '#f4f4f4', marginTop: 20}} />
                            <Flex style={{marginTop: 20, width: '100%'}}>
                                <Text style={{color: 'gray', width: '30%'}}>订单定金:</Text>
                                {this.state.orderinfo.OrderPayID === 0 && <Text style={{color: 'gray', width: '40%'}}>未付</Text>}
                                {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) && (
                                    <Text style={{color: 'gray', width: '40%'}}>
                                        {this.state.orderinfo.OrderPayID > 0 && this.state.orderinfo.DepositState === 1 && '已付已审'}
                                        {this.state.orderinfo.OrderPayID > 0 && this.state.orderinfo.DepositState === 0 && '已付待审'}
                                    </Text>
                                )}
                                {this.props.userinfo.identity === 11 && (
                                    <>
                                        {this.state.orderinfo.DepositState === 1 && <Text style={{color: 'gray', width: '40%'}}> 定金确认</Text>}
                                        {this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.DepositState === 0 && (
                                                <Text
                                                    onPress={() => {
                                                        this.AuditOrder(this.state.orderinfo.ParkingOrderID);
                                                    }}
                                                    style={styles.selectall}>
                                                    审核定金
                                                </Text>
                                            )}
                                    </>
                                )}
                                <Flex
                                    justify={'end'}
                                    style={{width: '30%'}}
                                    onPress={() => {
                                        (this.props.userinfo.identity === 11 || this.props.userinfo.identity === 8) &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.props.navigation.push('PaymentDetailed', {
                                                order_id: this.state.orderinfo.ParkingOrderID,
                                            });
                                        (this.props.userinfo.identity === 11 || this.props.userinfo.identity === 8) &&
                                            this.state.orderinfo.OrderPayID === 0 &&
                                            Toast.info('未支付定金，暂无支付信息');
                                    }}>
                                    <Text style={{color: '#E94F4F', fontWeight: '600', paddingRight: 10}}>{this.state.orderinfo.DepositPirce}元</Text>
                                    <Flex>
                                        <Image style={{width: 6.5, height: 12, paddingRight: 10}} source={require('~/assets/public/jiantou.png')} />
                                    </Flex>
                                </Flex>
                            </Flex>
                            <View style={{width: '100%', height: 1, borderWidth: 1, borderColor: '#f4f4f4', marginTop: 20}} />
                            <Flex style={{marginTop: 20, width: '100%'}}>
                                <Text style={{color: 'gray', width: '30%'}}>付款方式:</Text>
                                <View style={{width: '40%'}}>
                                    {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) &&
                                        this.state.orderinfo.OrderState === 1 && (
                                            <>
                                                {this.state.orderinfo.PayMode === 1 && this.state.orderinfo.PaidState === 0 && (
                                                    <Text style={{color: 'gray', width: '100%'}}>待传付款凭证</Text>
                                                )}
                                                {this.state.orderinfo.PayMode === 2 && this.state.orderinfo.BankApplyID === 0 && (
                                                    <Text style={{color: 'gray', width: '100%'}}>待上传零首付资料</Text>
                                                )}
                                            </>
                                        )}
                                    {this.props.userinfo.identity === 11 && this.state.orderinfo.OrderState === 1 && (
                                        <>
                                            {this.state.orderinfo.PayMode === 1 && this.state.orderinfo.PaidState === 0 && (
                                                <Text style={{color: 'gray', width: '100%'}}>暂无付款凭证</Text>
                                            )}
                                            {this.state.orderinfo.PaidState === 1 && <Text style={{color: 'gray'}}> 已上传付款凭证</Text>}
                                            {this.state.orderinfo.PayMode === 2 && this.state.orderinfo.BankApplyID === 0 && (
                                                <Text style={{color: 'gray', width: '100%'}}>暂无零首付资料</Text>
                                            )}
                                            {this.state.orderinfo.PayMode === 2 && this.state.orderinfo.BankApplyID > 0 && (
                                                <Text style={{color: 'gray', width: '100%'}}>已上传零首付资料</Text>
                                            )}
                                        </>
                                    )}
                                </View>
                                <Flex
                                    justify={'end'}
                                    style={{width: '30%'}}
                                    onPress={() => {
                                        this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.PayMode == 1 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.PaidState === 1 &&
                                            (this.props.userinfo.identity === 8 || this.props.userinfo.identity === 11) &&
                                            this.props.navigation.push('PayMoney', {
                                                orderid: this.state.parkorderid,
                                                parkid: this.state.ParkingDataID,
                                            });
                                        this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.PayMode == 2 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.BankApplyID > 0 &&
                                            (this.props.userinfo.identity === 8 || this.props.userinfo.identity === 11) &&
                                            this.props.navigation.push('PayLoan', {
                                                params: this.state.ParkingDataID,
                                                orderid: this.state.parkorderid,
                                            });
                                        this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.PaidState === 0 &&
                                            this.state.orderinfo.BankApplyID === 0 &&
                                            Toast.info('业主未上传资料，暂无详细信息');
                                    }}>
                                    <Text style={{color: '#333333', fontWeight: '600', paddingRight: 10}}>
                                        {this.state.orderinfo.PayMode == 1 ? '全款' : '0首付'}
                                    </Text>
                                    <Flex>
                                        <Image style={{width: 6.5, height: 12, paddingRight: 10}} source={require('~/assets/public/jiantou.png')} />
                                    </Flex>
                                </Flex>
                            </Flex>
                            {this.state.orderinfo.PayMode === 2 && (
                                <>
                                    <View style={{width: '100%', height: 1, borderWidth: 1, borderColor: '#f4f4f4', marginTop: 20}} />
                                    <Flex style={{marginTop: 20, width: '100%'}}>
                                        <Text style={{color: 'gray', width: '30%'}}>认购协议:</Text>
                                        {this.state.orderinfo.ContractState === 1 && <Text style={{color: 'gray', width: '40%'}}> 已签</Text>}
                                        {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) &&
                                            (this.state.orderinfo.ContractState === 6 || this.state.orderinfo.ContractState === 0) && (
                                                <Text style={{color: 'gray', width: '40%'}}> 待签</Text>
                                            )}
                                        {this.props.userinfo.identity === 11 && (
                                            <>
                                                {this.state.orderinfo.BankApplyID === 0 && this.state.orderinfo.ContractState === 6 && (
                                                    <Text style={styles.selectno}>待签协议</Text>
                                                )}
                                                {this.state.orderinfo.OrderState === 1 &&
                                                    this.state.orderinfo.OrderPayID > 0 &&
                                                    this.state.orderinfo.DepositState === 1 &&
                                                    this.state.orderinfo.BankApplyID > 0 &&
                                                    this.state.orderinfo.ContractState === 6 && (
                                                        <Text
                                                            onPress={() => {
                                                                this.ConfirmOrder(this.state.orderinfo.ParkingOrderID);
                                                            }}
                                                            style={styles.selectall}>
                                                            确认协议
                                                        </Text>
                                                    )}
                                            </>
                                        )}
                                        <Text style={{width: '40%'}} />
                                    </Flex>
                                </>
                            )}
                            <View style={{width: '100%', height: 1, borderWidth: 1, borderColor: '#f4f4f4', marginTop: 20}} />
                            <Flex style={{marginTop: 20, width: '100%'}}>
                                <Text style={{color: 'gray', width: '30%'}}>车位款确认:</Text>
                                {this.state.orderinfo.IsFullPay === 1 && <Text style={{color: 'gray', width: '40%'}}>确认收款</Text>}
                                {this.state.orderinfo.IsComplete === 1 && <Text style={{color: 'gray', width: '40%'}}>确认收款</Text>}
                                {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) && (
                                    <>
                                        {this.state.orderinfo.PayMode === 1 && this.state.orderinfo.IsFullPay === 0 && (
                                            <Text style={{color: 'gray', width: '40%'}}>待确认收款</Text>
                                        )}
                                        {this.state.orderinfo.PayMode === 2 && this.state.orderinfo.IsComplete === 0 && (
                                            <Text style={{color: 'gray', width: '40%'}}>待确认收款</Text>
                                        )}
                                    </>
                                )}
                                {this.props.userinfo.identity === 11 && (
                                    <>
                                        {this.state.orderinfo.PayMode === 2 &&
                                            this.state.orderinfo.BankApplyID === 0 &&
                                            this.state.orderinfo.IsComplete === 0 && <Text style={styles.selectno}>贷款尾款 </Text>}

                                        {this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.DepositState === 1 &&
                                            this.state.orderinfo.PayMode === 1 &&
                                            this.state.orderinfo.IsFullPay === 0 && (
                                                <Text
                                                    onPress={() => {
                                                        this.ConfirmFull(this.state.orderinfo.ParkingOrderID);
                                                    }}
                                                    style={styles.selectall}>
                                                    确认收款
                                                </Text>
                                            )}

                                        {this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.DepositState === 1 &&
                                            this.state.orderinfo.BankApplyID > 0 &&
                                            this.state.orderinfo.ContractState === 1 &&
                                            this.state.orderinfo.IsComplete === 0 && (
                                                <Text
                                                    onPress={() => {
                                                        this.ConfirmLoan(this.state.orderinfo.ParkingOrderID);
                                                    }}
                                                    style={styles.selectall}>
                                                    确认收款
                                                </Text>
                                            )}
                                        <Text style={{width: 70}} />
                                    </>
                                )}
                            </Flex>
                            <View style={{width: '100%', height: 1, borderWidth: 1, borderColor: '#f4f4f4', marginTop: 20}} />
                            <Flex style={{marginTop: 20, width: '100%'}}>
                                <Text style={{color: 'gray', width: '30%'}}>正式协议:</Text>
                                {this.state.orderinfo.AgreementState === 1 && <Text style={{color: 'gray', width: '40%'}}>已签</Text>}
                                {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) &&
                                    this.state.orderinfo.AgreementState === 6 && <Text style={{color: 'gray', width: '40%'}}>待签协议</Text>}
                                {this.props.userinfo.identity === 11 && this.state.orderinfo.AgreementState === 6 && (
                                    <>
                                        {this.state.orderinfo.AgreementState === 6 &&
                                            this.state.orderinfo.IsFullPay === 0 &&
                                            this.state.orderinfo.IsComplete === 0 && <Text style={styles.selectno}>待签协议</Text>}
                                        {this.state.orderinfo.PayMode === 1 &&
                                            this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.DepositState === 1 &&
                                            this.state.orderinfo.IsFullPay === 1 &&
                                            this.state.orderinfo.AgreementState === 6 && (
                                                <Text
                                                    onPress={() => {
                                                        this.ConfirmAgreeOrder(this.state.orderinfo.ParkingOrderID);
                                                    }}
                                                    style={styles.selectall}>
                                                    确认协议
                                                </Text>
                                            )}
                                        {this.state.orderinfo.PayMode === 2 &&
                                            this.state.orderinfo.OrderState === 1 &&
                                            this.state.orderinfo.OrderPayID > 0 &&
                                            this.state.orderinfo.DepositState === 1 &&
                                            this.state.orderinfo.ContractState === 1 &&
                                            this.state.orderinfo.IsComplete === 1 &&
                                            this.state.orderinfo.AgreementState === 6 && (
                                                <Text
                                                    onPress={() => {
                                                        this.ConfirmAgreeOrder(this.state.orderinfo.ParkingOrderID);
                                                    }}
                                                    style={styles.selectall}>
                                                    确认协议
                                                </Text>
                                            )}
                                    </>
                                )}
                                <Text style={{width: '30%'}} />
                            </Flex>
                            <View style={{width: '100%', height: 1, borderWidth: 1, borderColor: '#f4f4f4', marginTop: 20}} />
                            {this.state.packagelist != null && (
                                <Flex style={{marginTop: 20, width: '100%'}}>
                                    <Text style={{color: 'gray', width: '30%'}}>赠品套餐:</Text>
                                    {this.state.orderinfo.GiftState === 1 && this.props.userinfo.identity === 8 && (
                                        <Text style={{color: 'gray', width: '40%'}}> 已发放</Text>
                                    )}
                                    {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) &&
                                        this.state.orderinfo.GiftState === 0 && <Text style={{color: 'gray', width: '40%'}}>待发放</Text>}
                                    {this.props.userinfo.identity === 11 && (
                                        <>
                                            {this.state.orderinfo.IsFullPay === 0 &&
                                                this.state.orderinfo.IsComplete === 0 &&
                                                this.state.orderinfo.GiftState === 0 && <Text style={styles.selectno}>待发放</Text>}
                                            {this.state.orderinfo.OrderState === 1 &&
                                                this.state.orderinfo.GiftState === 0 &&
                                                this.state.orderinfo.ParkingPackageID > 0 &&
                                                ((this.state.orderinfo.PayMode === 1 && this.state.orderinfo.IsFullPay === 1) ||
                                                    (this.state.orderinfo.PayMode === 2 && this.state.orderinfo.IsComplete === 1)) && (
                                                    <Text
                                                        style={styles.selectall}
                                                        onPress={() => {
                                                            this.state.orderinfo.OrderDataID > 0
                                                                ? this.props.navigation.push('Packageupmoney', {
                                                                      orderid: this.state.orderinfo.OrderDataID,
                                                                      parkorderid: this.state.orderinfo.ParkingOrderID,
                                                                  })
                                                                : this.props.navigation.push('PackageComfire', {
                                                                      parkorderid: this.state.orderinfo.ParkingOrderID,
                                                                  });
                                                        }}>
                                                        去下单
                                                    </Text>
                                                )}
                                            {this.state.orderinfo.GiftState === 1 && this.props.userinfo.identity === 11 && (
                                                <Text
                                                    onPress={() => {
                                                        this.state.orderinfo.OrderDataID > 0 &&
                                                            this.props.navigation.push('Packageupmoney', {
                                                                orderid: this.state.orderinfo.OrderDataID,
                                                                parkorderid: this.state.orderinfo.ParkingOrderID,
                                                                xiangqing: 1,
                                                            });
                                                    }}
                                                    style={styles.selectall}>
                                                    查看详情
                                                </Text>
                                            )}
                                        </>
                                    )}
                                    <Flex
                                        justify={'end'}
                                        style={{width: '30%'}}
                                        onPress={() => {
                                            (this.props.userinfo.identity === 8 || this.props.userinfo.identity === 11) &&
                                                this.state.orderinfo.OrderState === 1 &&
                                                this.props.navigation.push('GiftList', {
                                                    params: this.state.packagelist.OrderDataID,
                                                });
                                        }}>
                                        <Text style={{color: '#333333', fontWeight: '600', paddingRight: 10}}>
                                            {this.state.packagelist != null && this.state.packagelist.PackageName}
                                        </Text>
                                        <Flex>
                                            <Image
                                                style={{width: 6.5, height: 12, paddingRight: 10}}
                                                source={require('~/assets/public/jiantou.png')}
                                            />
                                        </Flex>
                                    </Flex>
                                </Flex>
                            )}
                            {this.state.orderinfo.ParkingPlanItemID > 0 && (
                                <>
                                    <Flex style={{marginTop: 20, width: '100%'}}>
                                        <Text style={{color: 'gray', width: '30%'}}>返现金券:</Text>
                                        {this.state.orderinfo.CoinState === 1 && <Text style={{color: 'gray', width: '40%'}}> 已发放</Text>}
                                        {(this.props.userinfo.identity === 8 || this.props.userinfo.identity === 31) && (
                                            <Text style={{color: 'gray', width: '40%'}}>{this.state.orderinfo.CoinState === 0 && '待发放'}</Text>
                                        )}
                                        {this.props.userinfo.identity === 11 && (
                                            <>
                                                {this.state.orderinfo.CoinAdminState === 0 && this.state.orderinfo.CoinState === 0 && (
                                                    <Text style={styles.selectno}>待发放</Text>
                                                )}
                                                {this.state.orderinfo.CoinAdminState === 1 && this.state.orderinfo.CoinState === 0 && (
                                                    <Text
                                                        onPress={() => {
                                                            this.Comfirecoin(this.state.orderinfo.ParkingOrderID);
                                                        }}
                                                        style={styles.selectall}>
                                                        发放现金券
                                                    </Text>
                                                )}
                                            </>
                                        )}
                                        <Flex
                                            justify={'end'}
                                            style={{width: '30%'}}
                                            onPress={() => {
                                                this.props.navigation.push('ParkGetMoney', {
                                                    coinvalue: this.state.orderinfo.CoinValue,
                                                });
                                            }}>
                                            <Text style={{color: '#333333', fontWeight: '600', paddingRight: 10}}>
                                                {this.state.orderinfo.CoinValue}元
                                            </Text>
                                            <Flex>
                                                <Image
                                                    style={{width: 6.5, height: 12, paddingRight: 10}}
                                                    source={require('~/assets/public/jiantou.png')}
                                                />
                                            </Flex>
                                        </Flex>
                                    </Flex>
                                    <Flex align={'start'} style={{marginTop: 20, width: '100%'}}>
                                        <Text style={{color: 'gray', width: '30%'}}>得汽车:</Text>
                                        <Text style={{width: '40%'}} />
                                        <Flex
                                            justify={'end'}
                                            style={{width: '30%'}}
                                            onPress={() => {
                                                this.props.navigation.push('ParkGetCar', {
                                                    parkingplancarID: this.state.orderinfo.ParkingPlanCarID,
                                                });
                                            }}>
                                            <Text style={{color: '#333333', fontWeight: '600', paddingRight: 10}}>得汽车</Text>
                                            <Flex>
                                                <Image
                                                    style={{width: 6.5, height: 12, paddingRight: 10}}
                                                    source={require('~/assets/public/jiantou.png')}
                                                />
                                            </Flex>
                                        </Flex>
                                    </Flex>
                                </>
                            )}
                            <Flex align={'start'} justify={'between'} style={{marginTop: 20}}>
                                <Text style={{color: 'gray'}}>得车位:</Text>
                                <Flex
                                    justify={'end'}
                                    style={{width: '30%'}}
                                    onPress={() => {
                                        this.props.navigation.push('ParkPark');
                                    }}>
                                    <Text style={{color: '#333333', fontWeight: '600', paddingRight: 10}}>得车位</Text>
                                    <Flex>
                                        <Image style={{width: 6.5, height: 12, paddingRight: 10}} source={require('~/assets/public/jiantou.png')} />
                                    </Flex>
                                </Flex>
                            </Flex>
                        </View>
                    </View>
                    {this.props.userinfo.identity === 8 && (
                        <Flex direction={'column'} justify={'end'} align={'end'} style={{width: '100%'}}>
                            {(this.state.orderinfo.ContractState == 0 || this.state.orderinfo.ContractState == 6) &&
                                this.state.orderinfo.OrderState === 1 &&
                                this.state.packagelist != null && (
                                    <Text
                                        onPress={() => {
                                            (this.state.orderinfo.ContractState == 0 || this.state.orderinfo.ContractState == 6) &&
                                                this.state.orderinfo.OrderState === 1 &&
                                                this.changepackage();
                                        }}
                                        style={styles.buttom2}>
                                        更换套餐
                                    </Text>
                                )}
                            {this.state.orderinfo.OrderState === 1 &&
                                this.state.orderinfo.OrderPayID === 0 &&
                                this.state.orderinfo.ContractState === 0 && (
                                    <Text
                                        onPress={() => {
                                            this.payment(this.state.orderinfo.ParkingOrderID);
                                        }}
                                        style={styles.buttom1}>
                                        支付定金
                                    </Text>
                                )}
                            {this.state.orderinfo.PayMode == 1 &&
                                this.state.orderinfo.OrderPayID > 0 &&
                                this.state.orderinfo.OrderState === 1 &&
                                this.state.moneytype == 0 &&
                                this.state.orderinfo.ContractState != 1 &&
                                this.state.parkplanlist.PayLoan === 1 && (
                                    <Text
                                        onPress={() => {
                                            this.changebuy(2);
                                        }}
                                        style={styles.buttom1}>
                                        不付了，我要零首付
                                    </Text>
                                )}
                            {this.state.orderinfo.PayMode == 1 &&
                                this.state.orderinfo.OrderPayID > 0 &&
                                this.state.orderinfo.OrderState === 1 &&
                                this.state.orderinfo.ContractState != 7 &&
                                this.state.orderinfo.PaidState === 0 && (
                                    <Text
                                        onPress={() => {
                                            this.props.navigation.push('PayMoney', {
                                                orderid: this.state.parkorderid,
                                                parkid: this.state.ParkingDataID,
                                            });
                                        }}
                                        style={styles.buttom2}>
                                        {this.state.moneytype == 0 ? '立即上传尾款支付凭证' : '查看付款凭证'}
                                    </Text>
                                )}
                            {this.state.orderinfo.PayMode == 2 &&
                                this.state.orderinfo.OrderState === 1 &&
                                this.state.orderinfo.OrderPayID > 0 &&
                                this.state.loantype == 0 &&
                                this.state.orderinfo.ContractState != 1 && (
                                    <Text
                                        onPress={() => {
                                            this.changebuy(1);
                                        }}
                                        style={styles.buttom1}>
                                        不贷了，我要全款
                                    </Text>
                                )}
                            {this.state.orderinfo.PayMode == 2 &&
                                this.state.orderinfo.OrderPayID > 0 &&
                                this.state.orderinfo.OrderState === 1 &&
                                this.state.orderinfo.ContractState != 7 && (
                                    <Text
                                        onPress={() => {
                                            this.props.navigation.push('PayLoan', {
                                                params: this.state.ParkingDataID,
                                                orderid: this.state.parkorderid,
                                            });
                                        }}
                                        style={styles.buttom2}>
                                        {this.state.loantype == 0 ? '上传金融信息' : '查看金融信息'}
                                    </Text>
                                )}
                        </Flex>
                    )}
                </View>
            </ScrollView>
        );
    }
}

const styles = StyleSheet.create({
    wrapper: {
        backgroundColor: '#fff',
    },
    containerHorizontal: {
        flexGrow: 1,
        alignItems: 'center',
        justifyContent: 'center',
        height: 150,
    },
    containerVertical: {
        flexGrow: 1,
        alignItems: 'center',
        justifyContent: 'center',
        height: 150,
    },
    text: {
        color: '#fff',
        fontSize: 36,
    },
    images: {
        width: '100%',
        height: 150,
        marginTop: 10,
    },
    images2: {
        width: '100%',
        height: 50,
        marginTop: 10,
    },
    textfenge: {
        width: '100%',
        backgroundColor: '#F6F6F6',
        height: 2,
        marginTop: 20,
    },
    textfenges: {
        width: '100%',
        backgroundColor: '#F6F6F6',
        height: 10,
        marginTop: 20,
    },
    textfengess: {
        width: '100%',
        backgroundColor: '#F6F6F6',
        height: 35,
    },
    maxview: {
        width: '100%',
        height: 95,
        marginTop: 10,
        backgroundColor: '#FDEDEC',
        borderRadius: 10,
    },
    button: {
        fontSize: 12,
        alignSelf: 'flex-start',
        height: 25,
        borderRadius: 10,
        backgroundColor: '#FF3733',
        color: '#FFFFFF',
        textAlign: 'center',
        padding: 4,
        marginLeft: 5,
    },
    buttom1: {
        width: '92%',
        marginLeft: '4%',
        marginRight: '4%',
        borderRadius: 5,
        overflow: 'hidden',
        height: 40,
        color: '#FFFFFF',
        fontSize: 15,
        backgroundColor: '#E94F4F',
        textAlign: 'center',
        paddingTop: 10,
        marginTop: 10,
    },
    buttom2: {
        width: '92%',
        marginLeft: '4%',
        marginRight: '4%',
        borderRadius: 5,
        overflow: 'hidden',
        height: 40,
        color: '#FFFFFF',
        fontSize: 15,
        backgroundColor: '#EBA35A',
        textAlign: 'center',
        paddingTop: 10,
        marginTop: 10,
    },
    selectall: {
        color: 'white',
        width: '40%',
        height: 25,
        backgroundColor: '#ec4f46',
        borderRadius: 5,
        textAlign: 'center',
        fontSize: 15,
        paddingTop: 3,
    },
    selectno: {
        color: '#666666',
        width: '40%',
        height: 25,
        backgroundColor: '#f4f4f4',
        borderRadius: 5,
        textAlign: 'center',
        fontSize: 15,
        paddingTop: 3,
    },
});

export default connect(mapGetter)(MyOrderInfo);
